import { Component, OnInit, Input } from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {Location} from '@angular/common'

import { GetRTDataByKKSCodesService} from '../../../../share/services/get-rtdata-by-kkscodes.service'

@Component({
  selector: 'app-diagnostic-tool-station-overview',
  templateUrl: './station-overview.component.html',
  styleUrls: ['./station-overview.component.css']
})
export class StationOverviewComponent implements OnInit {
  public units:object;
  public id:number;
  @Input() startTime:string=""
  @Input() endTime:string=""
  constructor(
    private activeRoute : ActivatedRoute,
    private location:Location,
    private router: Router
  ){
    this.startTime = activeRoute.snapshot.params['startTime'];
    this.endTime = activeRoute.snapshot.params['endTime'];
    this.id = +activeRoute.snapshot.params['id'];
  }
  public spa:number=0;
  public companys: Array<any>= [
    {
      name:'洪家渡',
      "units": [
        {
          index: '1',
          status:  2
        },
        {
          index: '2',
          status:  1
        },
        {
          index: '3',
          status:  1
        }
      ]
    },
    {
      name:'东风',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index:'2',
          status:  1
        },
        {
          index: '3',
          status:  1
        },
        {
          index: '4',
          status:  1
        }
      ]
    },
    {
      name:'索风营',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  3
        },
        {
          index: '3',
          status:  1
        }
      ]
    },
    {
      name:'乌江渡',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  3
        },
        {
          index: '3',
          status:  1
        },
        {
          index: '4',
          status:  1
        },
        {
          index: '5',
          status:  2
        },
        {
          index: '6',
          status:  1
        }
      ]
    },
    {
      name:'构皮滩',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  1
        },
        {
          index: '3',
          status:  1
        },
        {
          index: '4',
          status:  1
        },
        {
          index: '5',
          status:  1
        }
      ]
    },
    {
      name:'思林',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  2
        },
        {
          index: '3',
          status:  1
        },
        {
          index: '4',
          status:  1
        }
      ]
    },
    {
      name:'沙坨',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  1
        },
        {
          index: '3',
          status:  1
        },
        {
          index: '4',
          status:  3
        }
      ]
    },
    {
      name:'大花水',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  1
        }
      ]
    },
    {
      name:'格里桥',
      "units": [
        {
          index: '1',
          status:  1
        },
        {
          index: '2',
          status:  1
        }
      ]
    }
  ]
  navigator() {
    this.router.navigate(['/pages/performance-analysis/device-overview',this.id])
  }

  ngOnInit() {
    if(this.id == 5) {
      this.spa = 1;
      this.companys = [{
        name:'洪家渡',
        "units": [
          {
            index: '1',
            status:  2
          },
          {
            index: '2',
            status:  1
          },
          {
            index: '3',
            status:  1
          }
        ]
      }]
    }
  }
  freshTime(startTime:string){
    let arr = startTime.split(";")
    this.startTime = arr[0];
    this.endTime = arr[1];
  }
  public goBack(flag?:boolean){
    if(flag){
      this.location.back()
    }
    else {
      this.router.navigate(['/pages/home'])
    }
  }
}
